/**
 * Licensed to Open-Ones Group under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Open-Ones Group licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a
 * copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package mks.webshop.dao;

import java.util.List;

import mks.webshop.entity.BasePanel;
import mks.webshop.entity.Category;
import mks.webshop.entity.Counter;
import mks.webshop.entity.Logo;
import mks.webshop.entity.Notice;
import mks.webshop.entity.Order;
import mks.webshop.entity.OrderDetail;
import mks.webshop.entity.PanelType;
import mks.webshop.entity.Product;
import mks.webshop.entity.Tab;
import mks.webshop.entity.User;
import mks.webshop.entity.Food;

/**
 * @author thachle
 */
public interface IMasterDao {
    
    /**
     * Setting language code.
     * @param langCd
     */
    void setLangCd(String langCd);
    
    /************************************************************************
     * Persistent interfaces for product category
     ************************************************************************/

    /**
     * Get all product categories level 1.
     * @return
     */
    List<Category> getCategoryList();
    /**
     * Get all product categories.
     * @return
     */
    List<Category> getAllCategoryList();
    /**
     * Get amount subcategories.
     * @return
     */
    int getAmountSubcategory (String catId, int catLevel);
    
    Category getCategoryId (String id);
    
    /**
     * Get amount subproduct.
     * @return
     */
    int getAmountSubproduct (String catId);
    /**
     * Get product categories by identifier.
     * @param id identifier to lookup
     * @param exact true means lookup exactly. false means lookup all categories contains given id.
     * @return
     */
    Category getCategoryById(String id);
    
    List<Product> getSubProductList(String catId);
    List<Product> getProductList();
    Product getProductById(String proId);
    List<Product> getAllSaleOffProductList();

    List<Category> getSubCategoryList(String catId, int level);
    List<Category> getParentCategoryList(String catId, int level);

    /**
     * Store category without saving sub categories and product.
     * @param cat product category
     * @return
     */
    
    boolean isExistedCat(String id);
    
    boolean isExistedPro(String id);
    
    boolean saveCat(Category cat);

    boolean deleteCatById(String id);
    
    boolean deleteCatByKey(Long key);
    
    boolean deleteProByKey(Long key);
    
    boolean deleteOrderByKey(Long key);
    
    /************************************************************************
     * Persistent interfaces for tab (horizontal menu)
     ************************************************************************/

    /**
     * Get all tabs.
     * @return tabs with order.
     */
    List<Tab> getTabList();
    
    boolean saveTab(Tab tab);
    boolean deleteTabById(String tabId);
    boolean deleteTabByKey(Long key);
    
    /************************************************************************
     * Persistent interfaces for HTML Panels
     ************************************************************************/
    boolean savePanel(BasePanel panel);

    boolean saveProduct(Product pro);
    
    boolean saveProductImage(Product pro);
    
    boolean saveLogo(Logo logo);
    
    Logo getLogo();
    

    BasePanel getPanel(PanelType type);
    List<BasePanel> getAllPanels();

	boolean deleteSubProByCat(Category cat);
	
	boolean deleteSubCatByCat(Category cat);

	List<Category> getAllSubCategoryList(String catId);

	List<Product> inverseList(List<Product> listPro);

	List<Product> getAllProductList();
	List<Product> getProductWithQuantity(List<Product> modList, int quantity);
	List<Product> getSubProductListSortingName(String catid);

	boolean saveNotice(Notice note);
	boolean saveUser(User user);
	
	Notice getNoticeById(String id);

	boolean deleteNoticeByKey(Long key);

	List<Notice> getAllNoticeList();
	List<Notice> getNoticeWithQuantity(List<Notice> modNoticeList, int quantity);

	List<Notice> inverseNoticeList(List<Notice> modNoticeList);

	User getUserById(String id);
	
	/// Service for Food class
	boolean saveFood(Food food);
	boolean deleteFood(long id);
	Food getFoodByCode(String code);
	List<Food> getAllFoodList();
	boolean saveFoodImage(Food food);
	List<Food> getFoodWithQuantity(List<Food> modFoodList, int quantity);
	List<Food> inverseFoodList(List<Food> modFoodList);

	List<Product> getListProductByName(String name);
	
	/// Service for Order and OrderDetail
	boolean saveOrder(Order order);
	boolean setIsDone(Order order, boolean isDone);
	Order getOrderByCode(String code);
	long getMaxOrderKey();
	List<Order> getAllOrder();
	public List<Order> getOrdersByState(boolean isDone);
	
	boolean saveOrderDetail(OrderDetail detail);
	List<OrderDetail> getOrderDetailByOrderCode(String code);
	public long computeBasePrice(List<OrderDetail> list);
	public boolean checkLogin(String username, String password);

	List<User> getAllUser();

	boolean deleteUserByKey(Long key);
	
	//Counter
	public boolean save(Counter counter, int increament);
	public Counter getCounter();
	
	boolean setProductIsSpecial(Product pro, int isSpecial);
}
